unit iniciar;
Interface

uses

Crt,Dos,Printer,Graph,ADC,EXTDR,GlobVar,
CalNVC,printgraf,escreva,show,graveArquivo,escrever;


var OldChoice  :  char;
    fixar      :  boolean;

procedure MyExitProc;
procedure Initialize;
Procedure IniciarVariaveis;
Procedure GravaImagem(X,Y,W,H :  integer);
Procedure PutImagem(X,Y,W,H  :  integer);
procedure MarcaCoord(x,y  :  integer;
                         S  :  string);
procedure LigaCursor;
procedure DesLigaCursor;
Procedure InicializeExitador;
Procedure INITIALIZE_AD;
Procedure Opcoes;
Procedure MarcaEscolha;
Procedure  MarcaOpcao;
Procedure Inicia_Tela;
Procedure Inicia_Tela2;
Procedure EscalaXY( x,y : integer);
Procedure MostraControle;
Procedure MostraControle2;
Procedure MostraControle3;
Procedure MostraResultados;
Procedure MostraResultados2;
Procedure MostraResultados3;
Procedure OndaM;
Procedure OndaF;
Procedure OndaEMG;
Procedure OndaS;
Procedure ClearBuf;
Procedure LimparVariaveis;


implementation

{$F+}
procedure MyExitProc;
begin
  ExitProc := OldExitProc; { Restore exit procedure address }
  CloseGraph;              { Shut down the graphics system }
end; { MyExitProc }
{$F-}
procedure Initialize;
{ Initialize graphics and report any errors that may occur }
var
  InGraphicsMode : boolean; { Flags initialization of graphics mode }
  PathToDriver   : string;  { Stores the DOS path to *.BGI & *.CHR }
begin
  { when using Crt and graphics, turn off Crt's memory-mapped writes }
  DirectVideo := False;
  OldExitProc := ExitProc;                { save previous exit proc }
  ExitProc := @MyExitProc;                { insert our exit proc in chain }
  PathToDriver := '';
  repeat

{$IFDEF Use8514}                          { check for Use8514 $DEFINE }
    GraphDriver := IBM8514;
    GraphMode := IBM8514Hi;
{$ELSE}
    GraphDriver := Detect;                { use autodetection }
{$ENDIF}

   InitGraph(GraphDriver, GraphMode, PathToDriver);
    ErrorCode := GraphResult;             { preserve error return }
    if ErrorCode <> grOK then             { error? }
    begin
        Writeln('Graphics error: ', GraphErrorMsg(ErrorCode));
      if ErrorCode = grFileNotFound then  { Can't find driver file }
      begin
        Writeln('Enter full path to BGI driver or type <Ctrl-Break> to quit:');
        Readln(PathToDriver);
        Writeln;
      end
      else
        Halt(1);                          { Some other error: terminate }
    end;
  until ErrorCode = grOK;
 Randomize;                { init random number generator }
  MaxColor := GetMaxColor;  { Get the maximum allowable drawing color }
  MaxX := GetMaxX;          { Get screen resolution values }
  MaxY := GetMaxY;
end; { Initialize }

Procedure IniciarVariaveis;
var ii,jj :  integer;

begin
     caminho:='c:\enmg';
     N_paginas:=1;
     PtInicial:=0;
     MostrarOn:=true;
     XO:=0;
     YO:=0;
     DeltaXO:=0;
     DeltaYO:=0;
     For ii:=1 to 7 do
     begin
       for jj:=1 to 7 do
       nervou.memI[ii,jj]:=0;
     end;
     for ii:=1 to 4 do begin
       for jj:= 1 to 7 do begin
       nervou.dados[ii,jj]:=#0;
       nervou.esp[jj]:=#0;
       end;end;
       for jj:=9 to 13 do nervou.dados[1,jj]:=#0;
       for ii:=1 to 7 do nervou.distancia[ii]:=0.0;
       for ii:=1 to 7 do nervou.nRate[ii]:=0;
       for ii:=1 to 7 do nervou.nDur[ii]:=0;
       for ii:=1 to 7 do nervou.PtY[ii]:=0;
end;



Procedure ClearBuf;
var l :  integer;
   ll,bb : integer;

begin
      If escape or escapeNVC  or escapeEMG then begin end else Mostra;
      u:=0;
      count:=0;
      n:=1;
      for v:=1 to 16000 do
      buffer[v]:=0;
      v:=0;
end;



Procedure LimparVariaveis;

var ii,jj :  integer;

begin
     caminho:='c:\enmg';
     PtInicial:=0;
     MostrarOn:=true;
     XO:=0;
     YO:=0;
     DeltaXO:=0;
     DeltaYO:=0;
     For ii:=1 to 7 do
     begin
       for jj:=1 to 7 do
       nervou.memI[ii,jj]:=0;
     end;
     for ii:=1 to 4 do begin
       for jj:= 1 to 7 do begin
       nervou.dados[ii,jj]:='';
       nervou.esp[jj]:=#0;
       nervou.dados[1,13]:='';
       clearbuf;
       ch:=#0;
       oldchoice:=#0;
       end;end;
       for ii:=1 to 7 do nervou.distancia[ii]:=0.0;
     (*  for ii:=1 to 7 do nervou.nRate[ii]:=0;
       for ii:=1 to 7 do nervou.nDur[ii]:=0;
       for ii:=1 to 7 do nervou.PtY[ii]:=0;*)

end;


Procedure GravaImagem(X,Y,W,H :  integer);

begin
  Size:=  ImageSize(x,y,x+w,y+h);
  GetMem(p,Size);
  GetImage(x,y,y+w,y+h,P^);
end;

Procedure PutImagem(X,Y,W,H  :  integer);

begin
  PutImage(x,y,p^,0);
  FreeMem(p,size);
end;

procedure MarcaCoord(x,y  :  integer;
                         S  :  string);
var OldX,OldY  :  Integer;

    OldFillInfo  :  array[1..2] of integer;

begin
  OldX:=GetX;
  OldY:=GetY;
  MoveTo(x,y);
  GetFillSettings(FillInfo);
  bar(x,y,x+150,y+9);
  OutText(S);
  Moveto(OldX,OldY);
end;


procedure LigaCursor;

begin
  GravaImagem(0,0,300,15);
  setFillStyle(0,1);
end;

procedure DesLigaCursor;

begin
  setFillStyle(11,9);
  PutImagem(0,0,300,15);
end;

Procedure InicializeExitador;

begin
  STATUS := SET_EXCT($3E0);
  Iduration:=1;
  SET_PERIODO(IDuration-1);
  {OUT_PORT_2(0);}
  Irate:=2;
END;

Procedure INITIALIZE_AD;


 var STATUS : INTEGER;
       ii:integer;

BEGIN
  tam:=32000;
  count:=0;
  Imem:=1;
  bd:=0;
  adsta:=0;
  conf:=$2D0;
  PrecLimp:=False;
  adinit(adsta);
  adini(bd);
  adconf(bd,conf);
  adlerstatus(bd,adsta);
  admodo(bd,0);
  canal:=0;
  vez:=false;
  adselcanal(bd,canal);
  ganho:=1;
  adganho(bd,ganho);
  cnt:=24000;
  {addefbuffer(bd,adbuf[1],tam);}
  iniciada:=True;
  IEScY:=8;
  IEscX:=1;
  with nervou do
   for ii:=1 to 7 do begin
        memI[ii,5]:=IescX;
        memI[ii,6]:=IescY;
        esp[ii]:=#0;
    end;
 end;


Procedure Opcoes;

var m  :  integer;

begin
      SetViewPort(0,0,GetMaxX,GetMaxY,True);
      setwritemode(0);
     If OpcoesON then
               begin
     setFillStyle(1,7);
     bar(0,465,609,479);
     bar(0,3,609,14);
     setcolor(0);
     For m:=1 to 8 do  OutTextXY(PosicaoX[m],posicaoY,'F'+Int2Str(m)+'-'+informe[m]);
     for m:=9 to 10 do OutTextXY(PosicaoX[m],470,'F'+Int2Str(m)+'-'+Informe[m]);
     for m:=11 to 15 do OutTextXY(PosicaoX[m],470,' sF'+Int2Str(m-10)+'-'+Informe[m]);
     OpcoesON:=false;
               end else
               begin
                  setFillStyle(1,7);
                  bar(0,465,609,479);
                  bar(0,3,609,14);
                  setcolor(0);
                  For m:=4 to 7 do  OutTextXY(PosicaoX[m+5],posicaoY,'F'+Int2Str(m+5)+'-'+Outrosinformes[m+5]);
                  {for m:=9 to 10 do OutTextXY(PosicaoX[m+5],470,'F'+Int2Str(m+5)+'-'+OutrosInformes[m]);}
                  for m:=11 to 15 do OutTextXY(PosicaoX[m],470,OutrosInformes[m-10]);
                  {SetFillStyle(0,6);
                  bar(10,465,639,479);
                  bar(10,3,639,14);}
                  OpcoesON:=true;
               end;
 setColor(15);
  SetViewPort(initx,inity,finx,finy,clipon);
  setfillstyle(1,8);
  setwritemode(1);
end;

Procedure OndaM;

var oldgain,newgain,k   :   integer;
escolha               :   char;

Begin
   {If dividido then Out_Port_2(13) else Out_port_2(5);}
   oldgain:=ganho;
   a:=0;
   IescY:=13;
   CorrigeY;
   defineganho;
   IEscX:=3;
   if (not escapeRp) then Irate:=4 else Irate:=1;
   Iduration:=2;
   setcolor(14);
   setfillstyle(11,9);
   WriteText(PosX+10*h,TamY-15,real2str(rate[IRate]));
   WriteText(PosX+15*h,TamY-15,real2str(duration[IDuration]));
   setcolor(15);
   setfillstyle(0,1);
   k:=0;
   {   newgain:=ganho;
       If oldgain<>newgain then begin
           ganho:=newgain;
           If ganho<>-1 then adganho(bd,ganho)
            else begin
                   adganho(bd,0);
                   Out_Port_2(13);
                 end;
         DefineCalibracaoY;
         end;}
    MudaX;
    MudaY;
    marcatexto(PosX,InitY+14*15,'Onda M');
End;


Procedure OndaF;

var oldgain,newgain   :   integer;
                  k   :   integer;

Begin
   a:=0;
   IEscY:=10;
   defineganho;
   CorrigeY;
   IEscX:=4;
   Irate:=1;
   Iduration:=2;
   setcolor(14);
   setfillstyle(11,9);
   WriteText(PosX+10*h,TamY-15,real2str(rate[IRate]));
   WriteText(PosX+15*h,TamY-15,real2str(duration[IDuration]));
   setcolor(15);
   setfillstyle(0,1);
   ganho:=-1;
   marcatexto(PosX,InitY+14*15,'Onda F');
  { If oldgain<>newgain then begin
      ganho:=newgain;
      if ganho<>-1 then adganho(bd,ganho)
      else begin
            adganho(bd,0);

           DefineCalibracaoY;
         end;}
       MudaX;
       MudaY;
End;

Procedure OndaEMG;
var oldgain,newgain   :   integer;
    k                 :   integer;

Begin
   k:=0;
   Limiar:=1000;
   a:=0;
   IEscY:=7;
   corrigeY;
   IEscX:=4;
   Irate:=2;
   Iduration:=1;
   newgain:=ganho;
       If oldgain<>newgain then begin
           ganho:=newgain;
           adganho(bd,ganho);
           DefineCalibracaoY;
         end;
         MudaX;
         MudaY;
{    MostraControle;}
End;

Procedure OndaS;

var newgain,oldgain   :   integer;

Begin
   escapeemg:=true;
   IEscY:=6;
   corrigeY;
   IEscX:=1;
   Irate:=1;
   defineganho;
   Iduration:=1;
   setcolor(14);
   setfillstyle(11,9);
   WriteText(PosX+10*h,TamY-15,real2str(rate[IRate]));
   Iduration:=Iduration+1;
   DiminueDuration;
   a:=0;
   {newgain:=ganho;
      If oldgain<>newgain then begin
         ganho:=newgain;
         adganho(bd,ganho);
          DefineCalibracaoY;
        end;}
    PrecLimp:=True;
    MudaX;
    MudaY;
    marcatexto(PosX,InitY+14*15,'S');
    ch:='s';
    Oldchoice:='s';
  End;





Procedure MarcaEscolha;

begin
   case nervou.esp[Imem] of
   'S','s' :   marcatexto(PosX,InitY+14*15,'S');
   'M','m' :   marcatexto(PosX,InitY+14*15,'Onda M');
   'F','f' :   marcatexto(PosX,InitY+14*15,'Onda F');
   'A','a' :   marcatexto(PosX,InitY+14*15,'Average');
   ' ',#0  :   marcatexto(PosX,InitY+14*15,'Escolha');
   end;
end;

Procedure  MarcaOpcao;

var m   :   integer;
cor     :   boolean;

begin
      case  ch of
        #59       :  m:=1;
        #60       :  m:=2;
        #61       :  m:=3;
        #62       :  m:=4;
        #63       :  m:=5;
        #64       :  m:=6;
        #65       :  m:=7;
        #66       :  m:=8;
        #68       :  m:=10;
        #84       :  m:=11;
        #85       :  m:=12;
        #86       :  m:=13;
        #87       :  m:=14;
        #88       :  m:=15;
     else informe[m]:='                                ' end;
     Marcatexto(PosX,InitY+14*15,informe[m]);
end;

Procedure Inicia_Tela;

   Begin
       SetViewPort(0,0,GetMaxX,GetMaxY,True);
       H:=15;
       Escalas;
       Indicador:=true;
       NumLinhas:=16;
       NumColunas:=15;
       SetGraphMode(2);
       SetWriteMode(1);
       SetBkColor(0);
       SetTextStyle(0, HorizDir,1);
       SetTextStyle(0, HorizDir,0);
       OutTextxy(InitX-50,FinY+8,' NEUROLAB       EXAME ELETRONEUROMIOGRAFICO');
       setwritemode(1);
   end;

Procedure Inicia_Tela2;

   Begin
       SetViewPort(0,0,GetMaxX,GetMaxY,True);
       NumLinhas:=16;
       NumColunas:=15;
       SetWriteMode(1);
       SetBkColor(0);
{      SetTextStyle(0, HorizDir,1);
       OutTextxy(InitX-100,FinY+8,' NEUROLAB              EXAME ELETRONEUROMIOGRAFICO');}
   end;

Procedure EscalaXY( x,y : integer);
var ii:integer;

begin
     setcolor(3);
     setwritemode(0);
     Line(x,y+1,x,y+42);
     line(x+1,y,x+48,y);
     OutTextXY(x-20,Y+20,'uV');
     OutTextXY(x+20,Y-20,'ms');
     setfillstyle(0,1);
     WriteText(MaxX-60,TamY-62,Int2Str(EscX[IEscX]));
     WriteText(MaxX-102,TamY-22,Int2Str(calibracao*EscY[IEscY]));
     setfillstyle(11,9);
     setwritemode(1);
     setcolor(15);
end;


Procedure MostraControle;
var
    n            :    integer;
    ViewPort     :   ViewPortType;
    Year,month,day,dayofweek : word;

begin
     SetViewPort(0,0,GetMaxX,GetMaxY,true);
     SetViewPort(PosXJanCont,PosYJanCont,TamX,TamY,True);
     GetViewSettings(ViewPort);
     setcolor(15);
     setfillstyle(11,9);
     ClearViewPort;
     PosX:=4;
     Bar(1,1,TamX-1,TamY-PosYJanCont-1);
     {rectangle(0,0,TamX,TamY-PosYJanCont);}
     WriteText(PosX,posY+PosYjanCont+2,'Exame# : ');
     GetDate(year,month,day,dayofweek);
     WriteText(PosX,posY+PosYjanCont+2+h,'Data:');
     WriteText(PosX+50,posY+PosYjanCont+2+h,int2str(day)+'/'+int2str(month)+'/'+int2str(year));
     WriteText(PosX,posY+PosYjanCont+2*h+2,'Nome:');
     WriteText(PosX,posY+PosYjanCont+3*h+2,'Id/Sx:');
     WriteText(PosX,posY+PosYjanCont+4*h+2,'Dr:');
     WriteText(PosX,posY+PosYjanCont+5*h+3,'Segmento: ');
     If OldPg=N_paginas-1 then setcolor(6) else setcolor(14);
     WriteText(PosX+15*h,TamY-75,' Pg '+Int2Str(N_paginas));
     setcolor(14);
     WriteText(PosX+2,TamY-40,'Hor    Vert    freq    dur ');


          case IEscY of
     0..3     :  begin
                   WriteText(PosX,TamY-30,' ms     nV     Hz      ms');
              end;
     4..12  :  begin
                   WriteText(PosX,TamY-30,' ms     uV     Hz      ms');
              end;
    13..16  :  begin
                   WriteText(PosX,TamY-30,' ms     mV     Hz      ms');
               end;
          end;



     WriteText(PosX,TamY-15,Real1Str(EscX[IEscX]/2));
     If IescY=1 then WriteText(PosX+5*h,TamY-15,real1Str(calibracao*EscY[IEscY]/2))
     else WriteText(PosX+5*h,TamY-15,real0Str(calibracao*EscY[IEscY]/2));
     WriteText(PosX+10*h,TamY-15,real2str(rate[IRate]));
     WriteText(PosX+15*h,TamY-15,real2str(duration[IDuration]));
     SetViewPort(initx,inity,finx,finy,clipon);
     setcolor(15);
end;

Procedure MostraControle2;
var
    n            :    integer;
    ViewPort     :   ViewPortType;
    Year,month,day,dayofweek : word;

begin
     SetViewPort(0,0,GetMaxX,GetMaxY,true);
     SetViewPort(PosXJanCont,PosYJanCont,TamX+1,TamY+1,True);
     setcolor(15);
     setfillstyle(11,9);
     {ClearViewPort;}
     PosX:=4;
     Bar(1,1,TamX-1,TamY-PosYJanCont-105);
     rectangle(0,0,TamX,TamY-PosYJanConT);
     SetViewPort(PosXJanCont,PosYJanCont,TamX,TamY-105,True);
     WriteText(PosX,posY+PosYjanCont+2,'Exame #: ');
     GetDate(year,month,day,dayofweek);
     WriteText(PosX,posY+PosYjanCont+2+h,'Data:');
     WriteText(PosX+50,posY+PosYjanCont+2+h,int2str(day)+'/'+int2str(month)+'/'+int2str(year));
     WriteText(PosX,posY+PosYjanCont+2*h+2,'Nome:');
     WriteText(PosX,posY+PosYjanCont+3*h+2,'Id/Sx:');
     WriteText(PosX,posY+PosYjanCont+4*h+2,'Dr:');
     WriteText(PosX,posY+PosYjanCont+5*h+3,'Segmento: ');
     SetViewPort(initx,inity,finx,finy,clipon);
     setcolor(15);
end;


Procedure MostraControle3;
var
    n            :    integer;
    ViewPort     :   ViewPortType;
    Year,month,day,dayofweek : word;

begin
     SetViewPort(0,0,GetMaxX,GetMaxY,true);
     SetViewPort(PosXJanCont,PosYJanCont,TamX,TamY,True);
     If OldPg=N_paginas-1 then setcolor(6) else setcolor(14);
     WriteText(PosX+15*h,TamY-75,' Pg '+Int2Str(N_paginas));
     setcolor(14);
     WriteText(PosX+2,TamY-40,'Hor    Vert    freq    dur ');


          case IEscY of
     0..3     :  begin
                   WriteText(PosX,TamY-30,' ms     nV     Hz      ms');
              end;
     4..12  :  begin
                   WriteText(PosX,TamY-30,' ms     uV     Hz      ms');
              end;
    13..16  :  begin
                   WriteText(PosX,TamY-30,' ms     mV     Hz      ms');
               end;
          end;

     WriteText(PosX,TamY-15,Real1Str(EscX[IEscX]/2));
     WriteText(PosX+5*h,TamY-15,Int2Str(calibracao*EscY[IEscY]));
     WriteText(PosX+10*h,TamY-15,real2str(rate[IRate]));
     WriteText(PosX+15*h,TamY-15,real2str(duration[IDuration]));
     SetViewPort(initx,inity,finx,finy,clipon);
     setcolor(15);
end;

{Programa CN}
(********************
Procedure MostraResultados;

var
    n            :    integer;
    ViewPort     :   ViewPortType;

begin
     SetViewPort(0,0,GetMaxX,GetMaxY,true);
     SetViewPort(PosX2JanCont,PosY2JanCont,Tam2X,Tam2Y,false);
     setcolor(15);
     ClearViewPort;
     {PosX:=InitX-205;}
     PosX:=4;
     Pos2Y:=2;
     setfillstyle(9,9);
     h:=12;
     Bar(1,1,Tam2X-1,Tam2Y-PosY2JanCont-1);
     rectangle(0,0,Tam2X,Tam2Y-PosY2JanCont);
     WriteText(PosX,pos2Y+PosY2janCont,'M');
     WriteText(PosX+15,pos2Y+PosY2janCont,'    Estimulo           Captacao      esp  dT(cm)');
     {WriteText(PosX,pos2Y+PosY2janCont+h,'#                                            cm');}
    { WriteText(PosX+hx+40,pos2Y+PosY2janCont,'L(ms) Ampl  D(ms) V(m/s)');}
     WriteText(PosX+hx+40,pos2Y+PosY2janCont,'L(ms) Ampl  D(ms) arEa');
     {WriteText(PosX+hx+40,pos2Y+PosY2janCont+h,' ms            ms  mVms');}
     {WriteText(PosX+hx,pos2Y+PosY2janCont+h,
     'm       estimulaca   capatacao vel.de conducao');}
     SetViewPort(initx,inity,finx,finy,clipon);
     setcolor(15);
end;



Procedure MostraResultados3;

var
    n            :    integer;
    ViewPort     :   ViewPortType;

begin
     SetViewPort(0,0,GetMaxX,GetMaxY,true);
     SetViewPort(PosX2JanCont,PosY2JanCont,Tam2X,Tam2Y,false);
     setcolor(15);
     {ClearViewPort;}
     {PosX:=InitX-205;}
     PosX:=4;
     Pos2Y:=2;
     h:=12;
     setfillstyle(11,9);
     Bar(0,0,Tam2X,Tam2Y-PosY2JanCont);
     WriteText(PosX,pos2Y+PosY2janCont,'M');
     WriteText(PosX+15,pos2Y+PosY2janCont,'   Estimulo          Captacao      esp    dT(cm)');
     {WriteText(PosX,pos2Y+PosY2janCont+h,'#                                            cm');}
     { WriteText(PosX+hx+40,pos2Y+PosY2janCont,'L(ms) Ampl  D(ms) V(m/s)');}
     WriteText(PosX+hx+40,pos2Y+PosY2janCont,'L(ms) Ampl  D(ms) arEa');
     {WriteText(PosX+hx+40,pos2Y+PosY2janCont+h,' ms            ms  mVms');}
     SetViewPort(initx,inity,finx,finy,clipon);
     setcolor(15);
end;


Procedure MostraResultados2;

var
    n            :    integer;
    ViewPort     :   ViewPortType;

begin
     SetViewPort(0,0,GetMaxX,GetMaxY,true);
     SetViewPort(PosX2JanCont,PosY2JanCont,Tam2X,Tam2Y,false);
     setcolor(15);
     {ClearViewPort;}
     {PosX:=InitX-205;}
     PosX:=4;
     Pos2Y:=2;
     h:=12;
     setfillstyle(11,9);
     Bar(0,0,Tam2X,Tam2Y-PosY2JanCont);
     WriteText(PosX,pos2Y+PosY2janCont,' ');
  WriteText(PosX+15,pos2Y+PosY2janCont,      '                          N E U R O L A B                ');
  WriteText(PosX+15,pos2Y+PosY2janCont+h+3,  '           Dra. Terezinha E.N.Prince - Dr.Jose Alcyr Nunes');
  WriteText(PosX+15,pos2Y+PosY2janCont+2*h+5,'         Rua Francisco A. Coutinho 238 - Cambui -Campinas SP');
  WriteText(PosX+15,pos2Y+PosY2janCont+4*h+5,'                          TEL (0192) 52 2526');
  WriteText(PosX+15,pos2Y+PosY2janCont+7*h+5,'                      Estudo de Conducao Nervosa');
    {WriteText(PosX+hx+40,pos2Y+PosY2janCont,'L(ms) Ampl   D(ms) arEa');}
     SetViewPort(initx,inity,finx,finy,clipon);
     setcolor(15);
end;

******************)

{programa ECN}

Procedure MostraResultados;

var
    n            :    integer;
    ViewPort     :   ViewPortType;

begin
     SetViewPort(0,0,GetMaxX,GetMaxY,true);
     SetViewPort(PosX2JanCont,PosY2JanCont,Tam2X,Tam2Y,false);
     setcolor(15);
     ClearViewPort;
     {PosX:=InitX-205;}
     PosX:=4;
     Pos2Y:=2;
     setfillstyle(9,9);
     h:=12;
     Bar(1,1,Tam2X-1,Tam2Y-PosY2JanCont-1);
     rectangle(0,0,Tam2X,Tam2Y-PosY2JanCont);

     WriteText(PosX,pos2Y+PosY2janCont,' ');
     WriteText(PosX+15,pos2Y+PosY2janCont,'   Estimulo         Registro               disT');
     WriteText(PosX+hx+35,pos2Y+PosY2janCont,'Laten  Ampl   Dura Veloc');

     SetViewPort(initx,inity,finx,finy,clipon);
     setcolor(15);
end;




Procedure MostraResultados2;

var
    n            :    integer;
    ViewPort     :   ViewPortType;

begin
     SetViewPort(0,0,GetMaxX,GetMaxY,true);
     SetViewPort(PosX2JanCont,PosY2JanCont,Tam2X,Tam2Y,false);
     setcolor(15);
     {ClearViewPort;}
     {PosX:=InitX-205;}
     PosX:=4;
     Pos2Y:=2;
     h:=12;
     setfillstyle(11,9);
     Bar(0,0,Tam2X,Tam2Y-PosY2JanCont);
     WriteText(PosX,pos2Y+PosY2janCont,' ');




WriteText(PosX+15,pos2Y+PosY2janCont,      '               Dr. Carlos Roberto DeFaria - Dra. Susanie Caldas');
WriteText(PosX+15,pos2Y+PosY2janCont+h+3,  '                          Neurofisiologia Clinica');
WriteText(PosX+15,pos2Y+PosY2janCont+2*h+3,'                                C E M E D I');
WriteText(PosX+15,pos2Y+PosY2janCont+3*h,  '                Rua 2 No. 657 Setor Oeste 74110-130 Goiania GO');
WriteText(PosX+15,pos2Y+PosY2janCont+4*h,  '                        TEL (062) 225 2326/229 2462');


  SetViewPort(initx,inity,finx,finy,clipon);
  setcolor(15);
end;




Procedure MostraResultados3;

var
    n            :    integer;
    ViewPort     :   ViewPortType;

begin
     SetViewPort(0,0,GetMaxX,GetMaxY,true);
     SetViewPort(PosX2JanCont,PosY2JanCont,Tam2X,Tam2Y,false);
     setcolor(15);
     {ClearViewPort;}
     {PosX:=InitX-205;}
     PosX:=4;
     Pos2Y:=2;
     h:=12;
     setfillstyle(11,9);
     Bar(0,0,Tam2X,Tam2Y-PosY2JanCont);

     WriteText(PosX,pos2Y+PosY2janCont,' ');
     WriteText(PosX+15,pos2Y+PosY2janCont,'   Estimulo         Registro               disT');
     WriteText(PosX+hx+35,pos2Y+PosY2janCont,'Laten  Ampl   Dura Veloc');



     SetViewPort(initx,inity,finx,finy,clipon);
     setcolor(15);
end;





end.